package com.to.controller;


import com.to.bean.User;
import com.to.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/show")
public class ShowServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // 获取所有用户信息,传递给show.jsp 页面
        UserService userService = new UserService();
        List<User> userList =  userService.selectAllUser();

        // 页面跳转, 选择作用域对象时考虑因素 1. 是否可以获取的到数据 2.内存的利用率
        req.setAttribute("ulist",userList);
        req.getRequestDispatcher("show.jsp").forward(req,resp);

    }
}
